package com.box.app.arithmetic

internal class Math(private val callable: Callable) : Symbol, Operable {
    override val priority = callable.priority

    @Throws(ArithmeticError::class)
    fun call(vararg values: Number) = callable.call(*values)

    override fun toDescribe(isTight: Boolean) = callable.name

    override fun toString() = toDescribe(true)

    companion object {
        fun of(s: String) = checkNotNull(MathFactory.maybeOf(s))
    }
}

internal expect object MathFactory {
    fun maybeOf(s: String): Math?
}